/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entidade;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author bruno
 */
@Entity
@Table(name = "moeda")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Moeda.findAll", query = "SELECT m FROM Moeda m"),
    @NamedQuery(name = "Moeda.findByIdMoeda", query = "SELECT m FROM Moeda m WHERE m.idMoeda = :idMoeda"),
    @NamedQuery(name = "Moeda.findByNomeMoeda", query = "SELECT m FROM Moeda m WHERE m.nomeMoeda = :nomeMoeda"),
    @NamedQuery(name = "Moeda.findByCodMoeda", query = "SELECT m FROM Moeda m WHERE m.codMoeda = :codMoeda"),
    @NamedQuery(name = "Moeda.findByCambioMoeda", query = "SELECT m FROM Moeda m WHERE m.cambioMoeda = :cambioMoeda")})
public class Moeda implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "idMoeda")
    private Integer idMoeda;
    @Size(max = 45)
    @Column(name = "nomeMoeda")
    private String nomeMoeda;
    @Size(max = 45)
    @Column(name = "codMoeda")
    private String codMoeda;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "cambioMoeda")
    private Float cambioMoeda;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idMoeda")
    private Collection<ContaMoeda> contaMoedaCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idMoeda")
    private Collection<MovimentoConta> movimentoContaCollection;

    public Moeda() {
        idMoeda=0;
        cambioMoeda=0f;
    }

    public Moeda(Integer idMoeda) {
        this.idMoeda = idMoeda;
    }

    public Integer getIdMoeda() {
        return idMoeda;
    }

    public void setIdMoeda(Integer idMoeda) {
        this.idMoeda = idMoeda;
    }

    public String getNomeMoeda() {
        return nomeMoeda;
    }

    public void setNomeMoeda(String nomeMoeda) {
        this.nomeMoeda = nomeMoeda;
    }

    public String getCodMoeda() {
        return codMoeda;
    }

    public void setCodMoeda(String codMoeda) {
        this.codMoeda = codMoeda;
    }

    public Float getCambioMoeda() {
        return cambioMoeda;
    }

    public void setCambioMoeda(Float cambioMoeda) {
        this.cambioMoeda = cambioMoeda;
    }

    @XmlTransient
    public Collection<ContaMoeda> getContaMoedaCollection() {
        return contaMoedaCollection;
    }

    public void setContaMoedaCollection(Collection<ContaMoeda> contaMoedaCollection) {
        this.contaMoedaCollection = contaMoedaCollection;
    }

    @XmlTransient
    public Collection<MovimentoConta> getMovimentoContaCollection() {
        return movimentoContaCollection;
    }

    public void setMovimentoContaCollection(Collection<MovimentoConta> movimentoContaCollection) {
        this.movimentoContaCollection = movimentoContaCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idMoeda != null ? idMoeda.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Moeda)) {
            return false;
        }
        Moeda other = (Moeda) object;
        if ((this.idMoeda == null && other.idMoeda != null) || (this.idMoeda != null && !this.idMoeda.equals(other.idMoeda))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Moeda[ idMoeda=" + idMoeda + " ]";
    }
    
}
